import axios from "axios";

console.log(import.meta.env)
let request = axios.create({
	baseURL: import.meta.env.VITE_BASE_URL,
	headers: {
		"Content-Type": "application/json",
	},
});

request.interceptors.request.use(
	config => {
		let token = localStorage.getItem("accessToken");
		if (token) {
			config.headers["Authorization"] = `Bearer ${token}`;
		}
		return config;
	},
	error => {
		return Promise.reject(error);
	}
);

request.interceptors.response.use(res => {
	res.res = res.data;
	return res;
});

export default request;
